package com.limingru.online_class.utils;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Data
@NoArgsConstructor
@Component
public class CacheUtil {
    private Cache<String, Object> tenMinutesCache = CacheBuilder.newBuilder()
            // 初始化缓存大小
            .initialCapacity(10)
            // 最大缓存数量
            .maximumSize(100)
            // 并发
            .concurrencyLevel(5)
            // 缓存过期时间
            .expireAfterWrite(600, TimeUnit.SECONDS)
            // 统计命中率
            .recordStats()
            .build();
}
